package csm.common.text;


import java.text.MessageFormat;
import java.util.regex.Pattern;

import csm.common.*;

public class HangulJamoTest {
	public static void main(String[] args)
	{
		try
		{
			// 한글관련 테스트.

			System.out
					.println("============================================================");
			System.out.println("Unicode 한글 분해 / 조합테스트");

			String uniChar = "뷁";
			HangulJamo jamo = UnicodeUtil.Korean.SplitHangul(uniChar);
			HangulJamo kscJamo = UnicodeUtil.Korean.SplitHangul2KSC(uniChar
					.charAt(0));

			System.out.println("오리지날 문자 : " + String.valueOf(uniChar.charAt(0))
					+ "(0x" + RadixUtil.getString(uniChar.charAt(0), 16) + ")");
			System.out.println("초성 : [유니코드 한글자모 - '" + jamo.CHOSUNG_Str
					+ "' (0x" + RadixUtil.getString(jamo.CHOSUNG, 16)
					+ ")], [유니코드 KSC자모 - '" + kscJamo.CHOSUNG_Str + "' (0x"
					+ RadixUtil.getString(kscJamo.CHOSUNG, 16) + ")]");
			System.out.println("중성 : [유니코드 한글자모 - '" + jamo.JUNGSUNG_Str
					+ "' (0x" + RadixUtil.getString(jamo.JUNGSUNG, 16)
					+ ")], [유니코드 KSC자모 - '" + kscJamo.JUNGSUNG_Str + "' (0x"
					+ RadixUtil.getString(kscJamo.JUNGSUNG, 16) + ")]");
			System.out.println("종성 : [유니코드 한글자모 - '" + jamo.JONGSUNG_Str
					+ "' (0x" + RadixUtil.getString(jamo.JONGSUNG, 16)
					+ ")], [유니코드 KSC자모 - '" + kscJamo.JONGSUNG_Str + "' (0x"
					+ RadixUtil.getString(kscJamo.JONGSUNG, 16) + ")]");
			System.out.println("다시 조합된 문자 : [유니코드 한글자모 -'" + jamo.getString()
					+ "'" + "(0x"
					+ RadixUtil.getString(jamo.getString().charAt(0), 16)
					+ ")], [유니코드 KSC자모 -'" + kscJamo.getString() + "'(0x"
					+ RadixUtil.getString(jamo.getString().charAt(0), 16)
					+ ")]");

			System.out.println("");

			System.out
					.println("============================================================");
			System.out.println("한자를 한글로 변환 테스트");
			char uniHanja = '漢';
			System.out.println("입력된 한자 : " + uniHanja + ",  변환된 한글 : "
					+ UnicodeUtil.Korean.HanjaToHangul(uniHanja));
			String uniHanjaStr = "大韓民國";
			System.out.println("입력된 한자문자열 : " + uniHanjaStr + ",  변환된 문자열 : "
					+ UnicodeUtil.Korean.HanjaToHangul(uniHanjaStr));
			System.out.println("");

			System.out
					.println("============================================================");
			System.out.println("진법 테스트.");
			System.out.println("16진수표현 FFFF를 10진수값으로 : "
					+ RadixUtil.parse("FFFF", 16));
			System.out.println("10진수표현 65535를 16진수표현으로 : "
					+ RadixUtil.getString(65535, 16));
			System.out.println("");

			System.out
					.println("============================================================");
			System.out.println("숫자를 한글/한문표현으로 변환 테스트");
			System.out.println("입력 : 1234567");
			System.out.println("한글표현 : "
					+ UnicodeUtil.Korean.DigitNumToHangul(1234567));
			System.out.println("한자표현 : "
					+ UnicodeUtil.Korean.DigitNumToHanja(1234567));
			System.out.println("");

			System.out
					.println("============================================================");
			System.out.println("형변환 테스트");
			System.out.println(TypeConv.ToDouble("lksjfsk"));
			System.out.println("");

			String s ;
			s = MessageFormat.format("{0}, {1}, {2}, {0}", "hello","hi",113);
			//s = String.format("{0}, {1}, {2}, {0}", "hello","hi","bye");
			System.out.println(s);


			String factor = "505??d";
			if (Pattern.matches("^[0-9][0-9][0-9]...(\\([0-9]+-[0-9]+\\))?$", factor)) {
			    System.out.println(factor);
			}

			String src = "(주)한국";
			System.out.println(src.replaceAll("\\(.*?\\)", ""));

		}
		catch (SMException sme)
		{
			sme.printStackTrace();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

	}

}
